package cn.itcast.nems.order.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

/**
 * 优惠券类型枚举
 * @author 高昌露
 * @since 2023/12/5 18:18
 */
@Getter
@AllArgsConstructor
public enum DiscountTypeEnum {
    CASH("金额优惠"),
    DISCOUNT("折扣优惠"),
    ;
    private final String desc;

    public static DiscountTypeEnum getByValue(@NonNull Integer value) {
        switch (value) {
            case 0 -> {
                return DiscountTypeEnum.CASH;
            }
            case 1 -> {
                return DiscountTypeEnum.DISCOUNT;
            }
            default -> throw new IllegalArgumentException("未知的优惠类型值: " + value);
        }
    }

}
